var CheckApplyFun={
	inits:function(){
		this.ajax();
		this.addBusinessFun();
	},
	Interface:{
		addmanufacturers:"http://ww.yc630.com/api/index.php/Buyer/User/addmanufacturers",  //商家入驻
	},
	ajax:function(){
		$("#file_upload").uploadify({
			swf:"./../uploadify/uploadify.swf",
			uploader:"http://ww.yc630.com/api/index.php/Seller/Seller/upload",
			fileTypeExts:"*.jpg;*.png",
			scriptAccess:"always",
			multi:true,  
			auto:true,//是否自动上传
			buttonText: "上传文件",//空间名称
			width: "56",
    		height: "56",
    		hideButton:true,
			onUploadSuccess:function(file,data,response){
				var res=JSON.parse(data),str="";
				$.each(res.data,function(i,v){
					console.log(v.image);
					str="<p><img src="+v.image+"></p>"
				});
				$("#BusinessPic").prepend(str);
			}
		});
	},
	addBusinessFun:function(){
		var subBtn=$("#subBtn"),
			name=$("#name"),
			compay_type=$("#compay_type"),
			brand_ids=$("#brand_ids"),
			contacts=$("#contacts"),
			job=$("#job"),
			customer_tel=$("#customer_tel"),
			addObj={};

		subBtn.on("click",function(){
			var licence_image=""
			if(common.checkNull(name.val())){
				alert("预约人姓名不能为空");
				return;
			}else if (common.checkNull(compay_type.val())) {
				alert("企业类型不能为空");
				return;
			}else if (common.checkNull(brand_ids.val())) {
				alert("品牌不能为空");
				return;
			}else if (common.checkNull(contacts.val())) {
				alert("联系人姓名不能为空");
				return;
			}else if (common.checkNull(job.val())) {
				alert("职称不能为空");
				return;
			}else if (common.checkNull(customer_tel.val())) {
				alert("联系方式不能为空");
				return;
			}else if ($("#BusinessPic img").length==0) {
				alert("请上传营业执照");
				return;
			}else {

				$("#BusinessPic").find("img").each(function(){
					licence_image+=$(this).attr("src")+",";
				});
				licence_image=licence_image.substring(0,licence_image.length-1)
				addObj={
					name:name.val(),
					compay_type:compay_type.val(),
					brand_ids:brand_ids.val(),
					contacts:contacts.val(),
					job:job.val(),
					licence_image:licence_image,
					customer_tel:customer_tel.val(),
					token:token
				}
		common.ajaxFun(CheckApplyFun.Interface.addmanufacturers,"POST",addObj,function(res){
			if (res.code==0) {
				alert(res.msg)
			}else{
				alert(res.msg)
			};
		}); //商家入驻
			}
		})
	}
}

CheckApplyFun.inits();